#ifndef _INCLUDE_H 
#define _INCLUDE_H 

/*  引入库*/
#include <Ticker.h>  //导入定时器库
#include <EEPROM.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <Arduino_JSON.h>

#define NO_Connect_Wifi 0
#define Connected_Wifi 1
#define NO_Connect_Server 2
#define Connected_Server 3
#define Error_Secretkey 9
#define Other_Status 10

#define Led_Blink_very_fast  50     //50ms
#define Led_Blink_General_fast 200  //200ms
#define Led_Blink_General_slow 1000  //1s
#define Led_Blink_very_slow 2000    //2s

WiFiClient client;

/*  延时器*/
long lastMsg_time = 0;

/*  先定义一个结构体，里面添加想要存储的数据类型*/
struct Config_wifi_struct{
    char ssid[20];
    char password[20];
};
Config_wifi_struct wifi_struct;

/*  先定义一个结构体，系统状态*/
struct System_status{
    char net_status = 0;
    char net_status_last = 0;
    char debug_str[50];
    String serial_buf = "";
    JSONVar json_object;
    String current_protocol = "";
    String client_CallBack_msg = "";
    int Led_blink_interval = 0;
    String secret_key = "";
    bool secret_key_value = false;
};
System_status system_status;

/*  先定义一个结构体，网络协议*/
struct Net_com_protocol{
    const char* tcp = "tcp";
    const char* udp = "udp";
    const char* mqtt = "mqtt";
    const char* post = "post";
    const char* get = "get";
};
Net_com_protocol net_com_protocol;

/*  TCP协议的几个参数*/
struct TCP_config_parameter{
    String ip_add = "";
    String ip_port = "";
    String msg = "";
};
TCP_config_parameter tcp_config_parameter;

/*  UDP协议的几个参数*/
struct UDP_config_parameter{
    String ip_add = "";
    String ip_local_port = "";
    String ip_remote_port = "";
    String msg = "";
    bool udp_status = false;
};
UDP_config_parameter udp_config_parameter;

/*  MQTT协议的几个参数*/
struct MQTT_config_parameter{
    String ip_add = "";
    String ip_port = "";
    String msg_status_type = "0"; //设置发布主题，还是订阅主题 
    String topic = "";
    String msg = "";
    String client_Id = "";
    String user_name = "";
    String user_pwd = "";
};
MQTT_config_parameter mqtt_config_parameter;

/*  HTTP协议的几个参数*/
struct HTTP_config_parameter{
    String server_ip = "";
    String parameter = "";
    String msg = "";
    bool http_status = false;
};
HTTP_config_parameter http_config_parameter;

#endif
